package com.shrct.businessprocess.customerservice.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.shrct.businessprocess.customerservice.proxy.RCContractInstallInfoAction;

public class RCContractInstallInfoManager implements IsSerializable {
  public static Boolean isActionValid(final RCContractInstallInfoAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case setAsRequired:{
    		return "waiting4Initialize".equals(state)||"notRequired".equals(state);
    	}
    	case setAsNotRequired:{
    		return "waiting4Initialize".equals(state);
    	}
    	case cancel:{
    		return "notRequired".equals(state)||"executing".equals(state);
    	}
    	case updateInfo:{
    		return "executing".equals(state);
    	}
    	case finish:{
    		return "executing".equals(state);
    	}
    	case sendMessage:{
    		return "executing".equals(state);
    	}
    	case doAddtoServiceRecords:{
    		return "executing".equals(state)||"finished".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final RCContractInstallInfoAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
